package cn.yunhe.services;

import cn.yunhe.dao.ITypeDaoMapper;
import cn.yunhe.entity.merchantsentity.Type;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.io.PrintWriter;

public class TypeServiceZhou {

    public int addType(Type type){
        SqlSession session = SqlSessionFactoryUtil.getSqlSession();
        ITypeDaoMapper typeDaoMapper = session.getMapper(ITypeDaoMapper.class);
        int result=0;
        if (type!=null){
            try{
                 result= typeDaoMapper.addType(type);
                session.commit();

            }finally {
                session.close();
            }
        }
        return result;


    }

    public boolean searchType(String type){
        SqlSession session = SqlSessionFactoryUtil.getSqlSession();
        ITypeDaoMapper typeDaoMapper = session.getMapper(ITypeDaoMapper.class);
        int result=typeDaoMapper.searchType(type);
        if (result>0){
            return true;
        }else {
            return false;
        }
    }
}
